<!--[if !lt IE 6]><!-->
<script type="text/javascript"> 
<!--//--><![CDATA[//><!--
$("html").addClass("js");
$(function() {
   $(".detail h4.expand").toggler({method: "slideFadeToggle"});
   $("div#filter_title").toggler({method: "slideToggle"});
   $("#entry_index").expandAll({trigger: "h4.expand", ref: "div.entry"});
   $(".select_date").datepicker({dateFormat: 'yy-mm-dd'});
});
//--><!]]>
</script> 
<!--<![endif]-->



<% if current_user %>
<div id="entry_control">
  <div>
  <%= link_to 'New entry', new_entry_path %>
  <br /><%= link_to 'Audit entries', 
    :controller => 'entries', :action => :audit %>
  </div>
</div>
<% end %>

<div id="content">
  <h2>Photoblog index</h2>
  <div id="content_body">
    <div id="index_filter">
      <div id="filter_form_container">
        <%= render :partial => "filter_form" %>
      </div>
      <div id="current_filters">
        <%= render :partial => "current_filters" %>
      </div>
    </div>

    <div id="entry_index">
      <div id="index_visible_range">
        <p>
          <% if @index_lower_limit > 1 %>
            <a id="show_newer" href="<%= @show_newer_href %>#entry_index">&lt;&lt;</a>
          <% else %>
            <span id="show_newer_disabled">&lt;&lt;</span>
          <% end %>
          <span id="index_range">
          <% if @entries.size <= 1 %>
            Showing entry <%= @index_offset + 1 %>
          <% else %>
            Showing entries
            <%= @index_offset + 1 %> to
            <%= @index_upper_limit %>
          <% end %>
          of <%= @non_limited_size %>
          </span>
        <% if @index_upper_limit < @non_limited_size %>
          <a id="show_older" href="<%= @show_older_href %>#entry_index">&gt;&gt;</a>
          <% else %>
            <span id="show_older_disabled">&gt;&gt;</span>
        <% end %>
        </p>
      </div>

      <% for @entry in @entries %>
        <div class="entry">
          <h3 class="entry_title">
            <%= link_to @entry.title, @entry %></h3>
          <div class="detail">
            <h4 class="expand">Details <span class="entry_date"><%= @entry.created_at.to_s.split(' ')[0] %></span></h4>
            <div class="collapse">
              <div class="entry_thumb">
                <%= render :partial => "thumbnail_img" %>
              </div>

              <div class="entry_details">
                <p class="description">
                  <% if @entry.description == "" %>
                    (no description)
                  <% else %>
                    <%=h @entry.description %>
                  <% end %>
                </p>
                <p><span class="entry_size"><%=h @entry.size %></span>
                  <% if @entry.size == 1 %>
                    image
                  <% else %>
                    images
                  <% end %>
                </p>
                <p>-<span class="author">
                  <%=h @entry.content_generator.username %></span>
                </p> 
              </div>
            </div>
          </div>
        <% if current_user && @entry.content_generator == current_user %>
          <div class="control"><td colspan="3">
            <span class="edit">
              <%= link_to 'Edit', edit_entry_path(@entry) %></span>
            <span class="delete"><%= link_to 'Destroy', @entry,
              :confirm => 'Are you sure?', :method => :delete %></span>
          </div>
        <% end %>
        </div>
      <% end %>
    </div>
    <% if @index_upper_limit < @non_limited_size %>
    <div class="result_page_nav">
      <a href="<%= @show_older_href %>#entry_index"> next page</a>
    </div>
    <% end %>
    <% if @index_lower_limit > 1 %>
    <div class="result_page_nav">
      <a href="<%= @show_newer_href %>#entry_index"> previous page </a>
    </div>
    <% end %>
  </div>
</div>
